package com.bookyourtrek.model;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import com.bookyourtrek.util.DbConnection;

public class RegisterModel {
	private PreparedStatement ps = null;
	private String sqlQuery = "";
	private Connection conn = null;

	/**
	 * function to insert new user entry into database
	 * @param email
	 * @param password
	 * @return true/false
	 */
	public boolean registerNewUser( String email, String password, String phone) {
		sqlQuery = "INSERT INTO `bookyourtrek`.`user`"
				+ " (`email`, `password`, `phone`) VALUES (?,?,?);";
		conn = DbConnection.getConnection();
		try {
			ps = conn.prepareStatement(sqlQuery);
			ps.setString(1, email);
			ps.setString(2, password);
			ps.setString(3, phone);
			ps.executeUpdate();
		} catch (SQLException e) {
			e.printStackTrace();
			return false;
		}finally {
			
		}
		return true;
	}
}
